﻿
function onLogin(){   	
    var name = document.getElementById("id-account").value;
	var password= document.getElementById("id-password").value;	
	//alert("name:"+name+",password:"+password);
	console.log("name:"+name+",password:"+password);
	LoginRequestForZepto(name,password);
}


function LoginRequestForZepto(name,password){
	console.log("LoginRequestForZepto---=");
	showToast("正在登录");
	var requestUrl="http://211.140.17.102:7080/monitor/service?method=login&userName="+name+"&password="+password;
	 console.log("requestUrl:"+requestUrl);
	$.ajax({
	type:"post",	
	url:requestUrl,
	success:function(returnData){ 
		console.log("returnData="+returnData);
		var flag = returnData.success;
		var  token =returnData.access_token;
		console.log("flag="+flag+",token="+token);
		//alert("flag="+flag+",token="+token);
			if(flag==1){
				if(token!=""){
					window.localStorage.setItem("accessToken",token);
					//var t= window.localStorage.getItem("accessToken");	
					window.location.href="Moniter.html";
				}
			}else{
				showToast('账号或密码错误');
			}
		}
	})
}

function showToast(message){
	document.getElementById("id-toast").style.display='block'; 
	document.getElementById("id-toast").style.opacity=1;         
	var msg='<div style="color:#fff;background: rgba(0, 0, 0, 0.6);border-radius: 2px;padding: 2px;text-align: center;width:175px;margin: 0 auto;">'+message+'</div>';
	document.getElementById("id-toast").innerHTML=msg;
	setTimeout(function(){
		document.getElementById("id-toast").style.opacity=0;
		setTimeout(function(){
					document.getElementById("id-toast").style.display='none';
		     }, 1000)
	},1000);
}

